package com.qwer.controller;

import com.qwer.entity.User;

import com.qwer.service.IUserService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author kk
 * @since 2023-02-23
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @PutMapping("updateUser")
    public R update(){
        return null;
    }

    @GetMapping("/list")
    public R list(){
        List<User> list = userService.list();
        return new R().setCode(100).setData(list);
    }
    @PostMapping("/post")
    public R save(@RequestBody User user ) {
        R r=new R();
        user.setCreateTime((Data) new Date());
        user.setStatus(1);
        String username = user.getUsername();
        boolean data=userService.save(user);
        return r.setCode(100).setData(data);
    }

}
